package org.ruoyi.knowledge.controller;

import lombok.RequiredArgsConstructor;
import org.ruoyi.knowledge.service.IDifyKnowledgeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dify")
@RequiredArgsConstructor
public class DifyKnowledgeController {

    private final IDifyKnowledgeService difyKnowledgeService;

    @GetMapping("/datasets")
    public String listDatasets(@RequestParam(required = false) Integer page,
                               @RequestParam(required = false, name = "pageSize") Integer pageSize) {
        return difyKnowledgeService.listDatasets(page, pageSize);
    }

    @GetMapping("/datasets/{datasetId}/documents")
    public String listDocuments(@PathVariable String datasetId,
                                @RequestParam(required = false) Integer page,
                                @RequestParam(required = false, name = "pageSize") Integer pageSize) {
        return difyKnowledgeService.listDocuments(datasetId, page, pageSize);
    }
}



